home *** CD-ROM | disk | FTP | other *** search
/ ftp.notepager.net / ftp.notepager.net.tar / ftp.notepager.net / pgv6.0.16.exe / [0] / pg.chm / helpman_topicinit.js < prev    next >
Text File  |  2013-02-13  |  16KB  |  449 lines

  1. ∩╗┐/* --------------- Script (c) 2006-2011 EC Software ---------------
  2. This script was created by Help & Manual. It is designed for use 
  3. in combination with the output of Help & Manual and must not
  4. be used outside this context.     http://www.helpandmanual.com
  5.  
  6. Do not modify this file! It will be overwritten by Help & Manual.
  7. -----------------------------------------------------------------*/
  8.  
  9. var topicInitScriptAvailable = true;
  10. var HMToggles = new Array();
  11. var HMGallery = new Array();
  12. var HMTogglesAllExpanded = false;
  13.  
  14. function hmmin(v1, v2) { if (v1<v2) return v1; return v2 }
  15. function hmmax(v1, v2) { if (v1>v2) return v1; return v2 }
  16.  
  17. var HMSyncTOC = function(indexPageUrl, selfUrl) {
  18.    if (location.search.lastIndexOf("toc=0")<=0) {
  19.      if (parent.hmNavigationFrame) { parent.lazysync(selfUrl); }
  20.      else if ((hmForceRedirect) && (parent.location) && (parent.location.href)) { parent.location.href = indexPageUrl+'?'+selfUrl; }
  21.    }
  22. }
  23.     
  24. var HMToggleExpandAll = function(value) {
  25.   if (HMToggles.length != null){ 
  26.     for (i=0; i<HMToggles.length; i++){ 
  27.       HMToggleExpand(HMToggles[i], value, (value && hmAnimate)); 
  28.     }
  29.   }
  30.   HMTogglesAllExpanded = value;
  31. }
  32.  
  33. var HMAnyToggleOpen = function() {
  34.   var anyOpen = false;
  35.   if (HMToggles.length != null){ 
  36.     for (i=0; i<HMToggles.length; i++){ 
  37.         if (HMToggles[i].getAttribute("hm.state")=='1') anyOpen = true; 
  38.     }
  39.   }
  40.   if (!anyOpen) HMTogglesAllExpanded = false;
  41.   return anyOpen;
  42. }
  43.  
  44. var HMToggle = function() { 
  45.     var op = HMToggle.arguments[0];
  46.     for (i=1; i<HMToggle.arguments.length; i++) {
  47.       var objID = HMToggle.arguments[i]; 
  48.              var obj = document.getElementById(objID);
  49.        switch (op) {
  50.         case "toggle": 
  51.           var state = obj.getAttribute("hm.state");
  52.           if (state == null) { state = "0" }; 
  53.           HMToggleExpand(obj, (state != "1"), hmAnimate);
  54.           break;
  55.  
  56.         case "expand":
  57.           HMToggleExpand(obj, true, false);
  58.           break;
  59.  
  60.         case "collapse":
  61.           HMToggleExpand(obj, false, false);
  62.           break;
  63.       }
  64.     }
  65. }
  66.  
  67. var HMToggleExpand = function(obj, value, animate) {
  68.     tagName = obj.nodeName.toLowerCase();
  69.     switch (tagName) {
  70.         case "span":
  71.           HMToggleExpandText(obj, value, animate);
  72.           break;
  73.         case "div":
  74.           HMToggleExpandDropdown(obj, value, animate);
  75.           break;
  76.         case "img":
  77.           HMToggleExpandPicture(obj, value, animate);
  78.           break;
  79.     }
  80.     obj.setAttribute("hm.state", value ? "1" : "0");
  81. }
  82.  
  83. var HMToggleExpandText = function(obj, value, animate) {
  84.   obj.style.display = (value ? "inline" : "none");  //cannot be animated
  85. }
  86.  
  87. var HMToggleExpandDropdown = function(obj, value, animate) {
  88.   if (animate) {
  89.     /* $(obj).stop(); don't stop here */ 
  90.     if (value) {
  91.       $(obj).slideDown('fast');
  92.     }
  93.     else {
  94.       $(obj).animate({ height: 'toggle' }, 'fast', function() {
  95.         if ($.browser.msie) { // Avoid collapsing margins bug in IE
  96.             var dummy = $(obj).prev();
  97.             if ($(dummy).outerHeight!=0) dummy = $('<div style="height:1px"></div>').insertBefore(obj);
  98.             else $(dummy).css('display', 'block');
  99.           $(dummy).css('display', 'none');
  100.         } 
  101.         });
  102.     } 
  103.   }
  104.   else {
  105.     obj.style.display = (value ? "block" : "none");
  106.   }
  107. }
  108.  
  109. var HMToggleExpandPicture = function(obj, value, animate) {
  110.   var newSrc = (value ? obj.getAttribute("hm.src1") : obj.getAttribute("hm.src0"));
  111.   var isToggleIcon = (obj.getAttribute("hm.type")=="dropdown");
  112.  
  113.   if ((!isToggleIcon) && (animate)) {
  114.     $(obj).stop(); 
  115.     
  116.     var newImg = new Image();
  117.     newImg.onload = function() {
  118.       var newWidth  = newImg.width;
  119.       var newHeight = newImg.height;
  120.         var oldWidth  = obj.width;
  121.         var oldHeight = obj.height;
  122.  
  123.       if ((newWidth > 0) && (newHeight > 0)) {
  124.         if ((newWidth == oldWidth) && (newHeight == oldHeight)) {
  125.           obj.src = newSrc;
  126.         }
  127.         else {
  128.           $(obj).animate({ width: newWidth, height: newHeight }, 'fast', function() {
  129.               obj.src = newSrc;
  130.           });
  131.           }
  132.         }
  133.     };
  134.     newImg.src = newSrc;
  135.   }
  136.   else { 
  137.     obj.src = newSrc;
  138.      $(obj).css('width', 'auto');
  139.     $(obj).css('height', 'auto');
  140.   }
  141.   var newTitle = (value ? obj.getAttribute("hm.title1") : obj.getAttribute("hm.title0"));
  142.   if (newTitle != null) { obj.title = newTitle; }
  143.   var newCaption = (value ? obj.getAttribute("hm.caption1") : obj.getAttribute("hm.caption0"));
  144.   if (newCaption != null) { obj.parentNode.parentNode.parentNode.nextSibling.firstChild.firstChild.innerHTML = newCaption; }
  145. }
  146.  
  147. var HMShowPictureLightbox = function(objID) {
  148.   var obj = document.getElementById(objID); /* our <img> clicked */
  149.  
  150.   var startL = $(obj).offset().left;
  151.   var startT = $(obj).offset().top;
  152.   var startW = $(obj).outerWidth();
  153.   var startH = $(obj).outerHeight();
  154.     
  155.   var newSrc = obj.getAttribute("hm.src1");
  156.   var newTitle = obj.getAttribute("hm.title1");
  157.   var newCaption = obj.getAttribute("hm.caption1");
  158.  
  159.   var htmlCode = '<img id="hmlightboximage" src="' + newSrc + '" alt="' + newTitle + '"/>';
  160.   var imgPreloader = new Image();
  161.   imgPreloader.onload = function() {
  162.       HMShowLightbox(htmlCode, startL, startT, startW, startH, imgPreloader.width, imgPreloader.height, newCaption, true, false); 
  163.   };
  164.   imgPreloader.src = newSrc;
  165.  
  166. }
  167.  
  168. var HMShowVideoLightbox = function(event, obj, htmlcode, vWidth, vHeight) {
  169.   var startL = $(obj).offset().left;
  170.   var startT = $(obj).offset().top;
  171.   var startW = $(obj).outerWidth();
  172.   var startH = $(obj).outerHeight();
  173.  
  174.   if (event.stopPropagation) { event.stopPropagation(); } else { event.cancelBubble = true; } //MSIE
  175.  
  176.   HMShowLightbox(htmlcode, startL, startT, startW, startH, vWidth, vHeight, '', false, true);
  177. }
  178.  
  179. var HMShowLightbox = function(htmlCode, startL, startT, startW, startH, endW, endH, newCaption, doAnimate, isVideo) {
  180.   /* Find our scope: 
  181.    * 1) Is this an orphan window or part of a webhelp frame?
  182.    * 2) If it is a webhelp frame, is it an iframe or classic <frame>?
  183.    * 3) Can we do cross-frame scripting? (not possible in Chrome locally) 
  184.    */
  185.   var parentScope = ((parent.hmNavigationFrame) && (parent.document.getElementById('hmnavigation')) && (parent.document.getElementById('hmnavigation').nodeName.toLowerCase()=='iframe'));
  186.   var lightboxWindow = $(window);
  187.   var lightboxDocument = $(document);
  188.   var lightboxBody = $('body');
  189.   var lighboxScrollLayer = null;
  190.   if (parentScope) {          /* use entire window for lightbox */
  191.       lightboxBody = parent.$('body');
  192.        lightboxDocument = parent.$(document);
  193.     lightboxWindow = parent.window;
  194.   }
  195.  
  196.   $(lightboxBody).append('<div id="hmlightboxbackground" style="z-index:99997;border:none;padding:0;margin:0;position:absolute;left:0;top:0;background-color:#7F7F7F"></div>');  
  197.   var lightboxBackground = parentScope ? parent.$('#hmlightboxbackground') : $('#hmlightboxbackground'); 
  198.   lightboxBackground.css('opacity', '0.5');
  199.  
  200.   if (parentScope) {
  201.       $(lightboxBody).append('<div id="hmlightboxscrolllayer" style="z-index:99998;border:none;padding:0;margin:0;position:absolute;left:0;top:0;background:none;overflow:auto"></div>');
  202.       lighboxScrollLayer = parent.$('#hmlightboxscrolllayer');
  203.       lightboxBody = lighboxScrollLayer;  
  204.   } 
  205.  
  206.   $(lightboxBody).append('<div id="hmlightbox" style="z-index:99999;position:absolute;display:none"></div>');
  207.   var lightbox = parentScope ? parent.$('#hmlightbox') : $('#hmlightbox');  
  208.   var lightboxObject = $(htmlCode).appendTo(lightbox);
  209.   var lightboxCaption = null;
  210.   if (newCaption != null) {
  211.       $(lightbox).append('<p id="hmlightboxcaption">' +newCaption+ '</p>');
  212.       lightboxCaption = parentScope ? parent.$('#hmlightboxcaption') : $('#hmlightboxcaption');
  213.   }      
  214.  
  215.   var lightboxSpeed = 300;
  216.   var sizeStart; /* keep initial size for hide animation */
  217.   var maxW = endW;
  218.   var maxH = endH;
  219.   if (hmLightboxConstrained) {
  220.     if (endW > ($(lightboxWindow).width()-40)) {
  221.       endW = $(lightboxWindow).width()-40;
  222.       if (endW < (maxW/2)) endW = maxW/2;
  223.       endH = maxH * endW / maxW;
  224.     }
  225.   }
  226.  
  227.   lightboxObject.css({'width': endW+'px', 'height': endH+'px'});
  228.   if (lightboxCaption!=null) lightboxCaption.css('width', endW+'px');
  229.       
  230.   if (hmAnimate&&doAnimate) {
  231.     var sizeEnd = lightboxGetsize();
  232.       if (lightboxCaption!=null) lightboxCaption.css('display', 'none'); /* hide caption during animation */
  233.     lightboxObject.css({'width': startW + 'px', 'height': startH + 'px'});
  234.       sizeStart = lightboxGetsize();
  235.     lightboxResize();
  236.          
  237.     sizeStart[0] = startL;
  238.     sizeStart[1] = startT;
  239.     if (parentScope) {
  240.       sizeStart[0] = sizeStart[0] + parent.$('#hmcontent').offset().left - $(document).scrollLeft();
  241.       sizeStart[1] = sizeStart[1] + parent.$('#hmcontent').offset().top - $(document).scrollTop();
  242.     }
  243.     lightbox.css({'left': sizeStart[0]+'px', 'top': sizeStart[1]+'px'});
  244.     lightbox.show();
  245.         
  246.     lightbox.animate({ left: sizeEnd[0]-lightboxObject.position().left, top: sizeEnd[1]-lightboxObject.position().top }, 
  247.                        lightboxSpeed, 
  248.                        function() { 
  249.                          if (lightboxCaption!=null) lightboxCaption.css('display', 'block');
  250.                        }
  251.                      );
  252.                          
  253.     lightboxObject.animate({ width: endW, height: endH }, lightboxSpeed); 
  254.   }
  255.   else {
  256.     var sizeEnd = lightboxGetsize();
  257.     lightboxResize();
  258.     lightbox.show();      
  259.   }  
  260.  
  261.   $(lightboxWindow).bind('resize.hmlightbox', lightboxResize);
  262.   $(lightboxWindow).bind('scroll.hmlightbox', lightboxScroll);
  263.   $(lightboxBody).bind('click.hmlightbox', lightboxClick);
  264.   $(lightboxBody).bind('keydown.hmlightbox', lightboxKeydown);
  265.   $(lightbox).focus();
  266.  
  267.   function lightboxScroll() {
  268.     lightboxBackground.css('width', (($(lightboxDocument).scrollLeft() > 0) ? $(lightboxDocument).width() : $(lightboxWindow).width()) +'px');
  269.     lightboxBackground.css('height', (($(lightboxDocument).scrollTop() > 0) ? $(lightboxDocument).height() : $(lightboxWindow).height()) +'px');
  270.   }
  271.       
  272.   function lightboxResize() {
  273.     if (hmLightboxConstrained) {
  274.       var tmpW = endW;
  275.       endW = $(lightboxWindow).width()-40;
  276.       if (endW > maxW) endW = maxW;
  277.       else if (endW < (maxW/2)) endW = maxW/2;
  278.       if (tmpW != endW) {
  279.         endH = maxH * endW / maxW;
  280.         lightboxObject.css({'width': endW+'px', 'height': endH+'px'});
  281.           if (lightboxCaption!=null) lightboxCaption.css('width', endW+'px');
  282.         }
  283.       }
  284.  
  285.       var size = lightboxGetsize();
  286.     lightbox.css({left: size[0]+'px', top:size[1]+'px'});
  287.     
  288.     if (lighboxScrollLayer!=null) { 
  289.       lighboxScrollLayer.css({'width': $(lightboxWindow).width()+'px', 'height': $(lightboxWindow).height()+'px'});
  290.     }
  291.     lightboxScroll();
  292.   }
  293.  
  294.   function lightboxGetsize() {
  295.       var lbW  = lightbox.width();
  296.       var lbH  = lightbox.height();
  297.  
  298.       if (isVideo) {
  299.         lbW = endW;
  300.         lbH = endH;
  301.     }
  302.       var newW = hmmax(lbW + 40, lightboxDocument.width());
  303.       var newH = hmmax(lbH + 40, lightboxDocument.height());
  304.  
  305.     var newL = hmmax(20, parseInt(($(lightboxWindow).width() - lbW)/2) + (parentScope ? 0 : lightboxDocument.scrollLeft()));
  306.     var newT = hmmax(20, parseInt(($(lightboxWindow).height() - lbH)/2) + (parentScope ? 0 : lightboxDocument.scrollTop()));
  307.  
  308.       var size = new Array(newL, newT, lbW, lbH);
  309.     return size;
  310.   }
  311.  
  312.   function lightboxKeydown(e) { 
  313.       if (e.keyCode == 27) lightboxClose(); 
  314.   }
  315.  
  316.   function lightboxClick(e) { 
  317.     var    canClose = (!isVideo) ||
  318.                    (e.pageX < lightbox.position().left) || (e.pageY < lightbox.position().top) ||
  319.                    (e.pageX > lightbox.position().left+lightbox.width()) || (e.pageY > lightbox.position().top+lightbox.height());       
  320.     if (canClose) lightboxClose(); 
  321.   }
  322.  
  323.   function lightboxClose() {
  324.       if (hmAnimate&&doAnimate) {
  325.       if (lightboxCaption!=null) lightboxCaption.css('display', 'none'); /* hide caption during animation */
  326.       lightboxObject.animate({ width: startW, height: startH }, lightboxSpeed); 
  327.       lightbox.animate({ left: sizeStart[0]-lightboxObject.position().left, top: sizeStart[1]-lightboxObject.position().top }, 
  328.                          lightboxSpeed, 
  329.                          function() { 
  330.                               lightbox.remove(); 
  331.                               if (lighboxScrollLayer!=null) lighboxScrollLayer.remove(); 
  332.                            lightboxBackground.remove();
  333.                        }
  334.                       );
  335.       }
  336.       else {
  337.       lightbox.remove();
  338.       if (lighboxScrollLayer!=null) lighboxScrollLayer.remove(); 
  339.         lightboxBackground.remove();
  340.       }
  341.     $(lightboxWindow).unbind('.hmlightbox');
  342.     $(lightboxBody).unbind('.hmlightbox');
  343.   }
  344.   
  345. }
  346.  
  347.  
  348.  
  349. var HMSearchCheck = function(obj) {
  350.   var foundHilite = window.location.search.lastIndexOf("zoom_highlight") > 0;
  351.   if (!foundHilite) {
  352.     var fontTags = obj.getElementsByTagName("FONT");
  353.     if (fontTags.length > 0) {
  354.       var hStyle = "";
  355.       for (var cCheck = 0; cCheck < fontTags.length; cCheck++) {
  356.         hStyle = fontTags[cCheck].style.cssText;
  357.         if (hStyle.indexOf("BACKGROUND-COLOR") == 0) {
  358.           foundHilite = true;
  359.           break; 
  360.         }
  361.       }
  362.     }
  363.   }
  364.   return foundHilite;     
  365. }
  366.  
  367. var HMInitToggle = function() {
  368.   if (document.getElementById) {
  369.     var node = document.getElementById(HMInitToggle.arguments[0]);
  370.     var isPicture = false;
  371.     for (i=1; i<HMInitToggle.arguments.length-1; i=i+2) { 
  372.         if (HMInitToggle.arguments[i] == "onclick") {
  373.           node.onclick = Function(HMInitToggle.arguments[i+1]); 
  374.         }
  375.         else { 
  376.           node.setAttribute(HMInitToggle.arguments[i], decodeURI(HMInitToggle.arguments[i+1]));
  377.           if ((HMInitToggle.arguments[i] == "hm.type") && (HMInitToggle.arguments[i+1] == "picture")) { isPicture = true; } 
  378.         }
  379.         if (HMInitToggle.arguments[i].substring(0,6) == "hm.src") {
  380.             var img = new Image();
  381.             img.src = HMInitToggle.arguments[i+1];
  382.         }
  383.     }
  384.     if (isPicture) {
  385.        var aLink = node.parentNode;
  386.        if (aLink.nodeName.toLowerCase() == "a") {
  387.             if (hmImageLightbox) {
  388.              HMGallery[HMGallery.length] = node;
  389.            aLink.href = "javascript:HMShowPictureLightbox('" + HMInitToggle.arguments[0] +"')";
  390.             }
  391.             else {
  392.              HMToggles[HMToggles.length] = node;
  393.            aLink.href = "javascript:HMToggle('toggle','" + HMInitToggle.arguments[0] +"')";
  394.            }
  395.        }
  396.     }
  397.     else {
  398.       var mustExpand = HMSearchCheck(node); 
  399.       HMToggles[HMToggles.length] = node;
  400.       if (mustExpand) { 
  401.         node.setAttribute("hm.state", "1"); 
  402.         var nodeImg = document.getElementById(node.getAttribute("id")+'_ICON');
  403.         if (nodeImg) { HMToggleExpand(nodeImg, true); }
  404.       }
  405.       HMToggleExpand(node, ((node.getAttribute("hm.state") == "1") || mustExpand));
  406.     }
  407.   }
  408. }
  409.  
  410. var HMTrackTopiclink = function(obj) {
  411.     if (parent.frames.length>0) {
  412.       if (parent.gaaccount) { parent.track("exit", obj.href); }
  413.     }
  414. }
  415.  
  416. var hmshowPopup = function(event, txt, trigger) {
  417.  
  418.     $('#hmpopupdiv').stop().remove();
  419.          
  420.     var pop = $('<div id="hmpopupdiv"></div>').appendTo('body');
  421.     if (hmPopupSticky) { 
  422.       $('body').bind('mouseup.hmpopup', hmhidePopup);
  423.       $('body').bind('keydown.hmpopup', function(e) { if (e.keyCode == 27) hmhidePopup(); } ); 
  424.     }          
  425.     pop.html(txt);
  426.     var posLeft = event.clientX+$(document).scrollLeft();
  427.     var posTop =  event.clientY+$(document).scrollTop();
  428.  
  429.     var maxW = $(window).width()/1.5;
  430.     var w = pop.width();
  431.     if (w > maxW) pop.width(maxW);
  432.     var t = 20 + posTop;           
  433.     var l = (posLeft - w/2);
  434.     if (l < 10) l = 10;
  435.     if ((l + pop.outerWidth()) > $(window).width()) l = $(window).width() - pop.outerWidth();
  436.     if (l < 0) l = 0;
  437.     pop.css( { left: l+'px', top: t+'px'} );
  438.     if (hmAnimate) pop.show('fast');
  439.     else pop.show();
  440. }
  441.  
  442. var hmhidePopup = function() { 
  443.     if (hmPopupSticky) $("body").unbind(".hmpopup");
  444.     var pop = $('#hmpopupdiv');
  445.     if (pop.length>0) {  //hide, don't remove
  446.       if (hmAnimate) pop.hide('fast');
  447.       else $(hmpopupdiv).hide();
  448.     } 
  449. }